package org.su.generalmvc.util;


import org.su.generalmvc.entity.FormFile;

/**
 * 
 * @author yangchuan createtime:2011-6-1下午1:30:44
 *
 */
public class FormFileArray {
	private static int len = 10;
	
	private FormFile items[] = null;
	private int size = 0;
	private FormFile data[] = null;
	
	public FormFileArray(){
		this(len);
	}

	public FormFileArray(int length) {
		items = new FormFile[length];
	}
	
	public void add(FormFile str){
		
		if(size == items.length-1){
			FormFile temp[] = new FormFile[2*items.length];
			System.arraycopy(items, 0, temp, 0, items.length);
			items = temp;
		}
		items[size] = str;
		size++;
	}
	
	public FormFile get(int i){
		return items[i];
	}
	
	public int getSize(){
		return size;
	}
	
	public FormFile[] toArray(){
		if(data == null || data.length < size){
			data = new  FormFile[size];
			System.arraycopy(items, 0, data, 0, size);
		}
		return data;
	}
}
